#include <iostream>
using namespace std;
void loc(string ruta, string &carpeta,string &extension);
int main()
{
    string carpeta, extension;
    loc("c:\\mis doc\\algo.doc",carpeta, extension);
    cout<<carpeta<<" "<<extension;
    return 1;
}
void loc(string ruta, string &carpeta,string &extension)
{
    int a,b,c;
    a=ruta.length();
    while(a!=-1)
    {
        if(ruta[a]=='.')
        {
            extension=ruta.substr(a+1,ruta.length()-a);
        }
        a--;
    }
        a=ruta.length();
        while(a!=-1)
        {
            if(ruta[a]=='\\')
            {
               c=a;
                a--;
                while(a!=-1)
                {
                    if(ruta[a]=='\\')
                    {
                        b=a;
                        break;
                    }
                    a--;
                }
                carpeta=ruta.substr(b+1,(c-b)-1);
                break;
            }
            a--;
        }

    }
    return;
}


